package com.woniuxy;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: 马宇航
 * @Todo: 全局异常处理器
 * @DateTime: 22/02/11/0011 下午 3:06
 * @Component: 成都蜗牛学苑
 **/
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    @ResponseBody
    public String handlerException(Exception e, Model model){
        System.out.println(e.getMessage());
        model.addAttribute("msg",e.getMessage()+"可选：服务器正在维护中……");
        return e.getMessage()+"可选：服务器正在维护中……";
    }
}
